#!/usr/bin/env python
# -*- coding: utf-8 -*-


import os
import json
from typing import List

from commons.logger import log
from config.path import DATA_DIR


def get_data(file: str, key: str):
    """
    json文件读取
    :param key:
    :param file: 文件路径
    :return:
    """
    file = os.path.join(DATA_DIR + "/json", file)
    try:
        with open(file, 'r', encoding='utf-8') as f:
            data = json.load(f)
            # pop_comment(data[key])
            lst = pop_key(data[key])
        return lst
    except FileNotFoundError as e:
        log.error(e)


def pop_comment(data: List = None):
    """删除场景说明_scene"""
    for v in data:
        if '_scene' in v:
            v.pop('_scene')


def pop_key(data: List = None):
    parametrize_data = []
    for v in data:
        parametrize_data.append(tuple(v.values()))
    return parametrize_data


if __name__ == '__main__':
    json_data = get_data('json_data.json', key='login_case')
    print(json_data)
